package org.charles.zhifou.model.dto.question;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Min;
import lombok.Data;
import org.charles.zhifou.common.enums.CodeToEnumDeserializer;
import org.charles.zhifou.enums.SqlSortOrderEnum;

import java.io.Serial;
import java.io.Serializable;

/**
 * 查询题目请求
 *
 * @author Charles
 * @version 1.0
 */
@Data
public class QuestionQueryRequest implements Serializable {

    @Schema(description = "id")
    @Min(value = 1, message = "id 必须大于 0")
    private Long id;

    @Schema(description = "题目内容 (JSON)")
    // 作为 SQL 查询条件, 数据库中存储的是 String, 因此为 String
    private String questionContent;

    @Schema(description = "应用 id")
    @Min(value = 1, message = "应用 id 必须大于 0")
    private Long appId;

    @Schema(description = "创建用户 id")
    @Min(value = 1, message = "创建用户 id 必须大于 0")
    private Long userId;

    @Schema(description = "id")
    @Min(value = 1, message = "不搜索的创建用户 id 必须大于 0")
    private Long notId;

    @Schema(description = "当前页号")
    @Min(value = 1, message = "当前页号必须大于 0")
    private int current = 1;

    @Schema(description = "页面大小")
    @Min(value = 1, message = "页面大小必须大于 0")
    private int pageSize = 10;

    @Schema(description = "排序字段")
    private String sortField;

    @Schema(description = "排序顺序 (默认升序)")
    @JsonDeserialize(using = CodeToEnumDeserializer.class)
    private SqlSortOrderEnum sortOrder = SqlSortOrderEnum.ASC;

    @Serial
    private static final long serialVersionUID = 1L;
}